package ee.siimkaspar.subjects.interceptor;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ValidationAware;
import com.opensymphony.xwork2.interceptor.Interceptor;

public abstract class BaseInterceptor implements Interceptor, StrutsStatics {

	protected static final String NOT_LOGGED_IN = "not_logged_in";
	protected static final String USER_DOESNT_EXIST = "user_doesnt_exist";
    protected static final String UNAUTHORIZED = "unauthorized";
    protected static final String SESSION_EXPIRED = "session_expired";
    
    public void destroy() {
    }

    public void init() {
    }
    
    protected void addActionError(ActionInvocation ai, String errorMsg) {
        if (ai.getAction() instanceof ValidationAware) {
            ((ValidationAware) ai.getAction()).addActionError(errorMsg);
        }
    }
}
